import React from "react"

export default class SearchInput extends React.Component{
	constructor(){
		super();
		this.state = {
			value : ""
		}
	}
	changeHandle(e){
		this.setState({
			value: e.target.value
		});
	}
	keyUpHandle(e){
		if( e.keyCode === 13 ){
			this.props.enterHandle(this.state.value);
		}
	}
	render(){
		return(
			<input 
				className="search-input" 
				type="text" 
				placeholder="搜索" 
				onChange={ this.changeHandle.bind(this) } 
				onKeyUp={ this.keyUpHandle.bind(this) }
				value={ this.state.value }
			/>
		)
	}
}
